# 移除md5相同的文件
import os
import hashlib
cwd = os.getcwd()
cdr = os.listdir(cwd)
lta = []
for fm in cdr:
    if '-10.txt' in fm:
        lta.append(fm)

print(lta)
lth = []
ltb = []
ltr = []
for fm in lta:
    with open(fm, encoding='utf-8') as fo:
        cnt = fo.read()
        md5h = hashlib.md5(cnt.encode('utf-8'))
        md5 = md5h.hexdigest()
        if md5 in lth:
            print(fm)
            ltr.append(fm)
            # os.remove(fm)
        else:
            ltb.append(fm)
            lth.append(md5)

for fm in ltr:
    print(fm)
    os.remove(fm)
# print('ltb', ltb)
# print('md5', lth)
#    os.remove(fm)
# else:
#     lth.append(md5)
